<breadcrumbs></breadcrumbs>

<div class="content-container">

    <div id="pkg-title">
        <div id="pkg-title-feed">
            <img src="/img/feed.svg" ng-click="goPkgFeedBuilder()">
        </div>
        <div id="pkg-title-icon">
            <pkg-icon size="32" pkg="pkg"></pkg-icon>
        </div>
        <div id="pkg-title-text">
            <h1>
                {{pkg.versions[0].summary}}
            </h1>
            <div class="muted">
                <small>
                    <pkg-label pkg="pkg"></pkg-label>
                    -
                    <version-label version="pkg.versions[0]"></version-label>
                    -
                    {{pkg.versions[0].architectureCode}}
                </small>
            </div>
        </div>
    </div>

    <div ng-show="canShowDerivedRating()" id="pkg-rating-indicator-container">
        <rating-indicator rating="pkg.derivedRating"></rating-indicator>
        <span class="pkg-ratings-indicator-sample">
            <small>
                <message
                        key="viewPkg.derivedUserRating.sampleSize"
                        parameters="[pkg.derivedRatingSampleSize]"></message>
            </small>
        </span>
    </div>

    <div id="pkg-screenshot-container" ng-show="pkgScreenshots.length">

        <div class="pkg-screenshot-item-container" ng-repeat="pkgScreenshot in pkgScreenshots">
            <div class="pkg-screenshot-item-controls-container">
                {{$index+1}}
                <a href="{{pkgScreenshot.imageDownloadUrl}}" target="_blank" ng-show="pkgScreenshots.length">
                    <img src="/img/download.svg">
                </a>
                <a href="{{pkgScreenshot.imageLargeUrl}}" target="_blank" ng-show="pkgScreenshots.length">
                    <img src="/img/newwindow.svg">
                </a>
            </div>
            <img ng-src="{{pkgScreenshot.imageThumbnailUrl}}">
        </div>

    </div>

    <div id="pkg-description-container" ng-show="pkg.versions[0].description">
        <p>
            <plain-text-content value="pkg.versions[0].description"></plain-text-content>
        </p>
    </div>

    <div id="pkg-metadata-container">

        <dl>
            <dt ng-show="pkg.title"><message key="viewPkg.name.title"></message></dt>
            <dd ng-show="pkg.title">{{pkg.name}}</dd>
            <dt><message key="viewPkg.isLatest.title" parameters="[pkg.versions[0].architectureCode]"></message></dt>
            <dd><boolean-indicator state="!!pkg.versions[0].isLatest"></boolean-indicator></dd>
            <dt ng-show="undefined!=pkg.versions[0].payloadLength"><message key="viewPkg.payloadLength.title"></message></dt>
            <dd ng-show="undefined!=pkg.versions[0].payloadLength">
                {{pkg.versions[0].payloadLength|dataLength}} <span class="muted">({{pkg.versions[0].payloadLength}} B)</span>
            </dd>
            <dt ng-show="undefined!=pkg.versions[0].sourcePkg"><message key="viewPkg.sourceAvailable.title"></message></dt>
            <dd ng-show="undefined!=pkg.versions[0].sourcePkg">
                <boolean-indicator state="!!pkg.versions[0].sourcePkg"></boolean-indicator>
            </dd>
            <dt><message key="viewPkg.categories.title"></message></dt>
            <dd>
                <span ng-show="!pkgCategories">...</span>
                <span ng-show="pkgCategories && !pkgCategories.length">
                    <message key="viewPkg.categories.none"></message>
                </span>
                <span ng-show="pkgCategories.length"><span ng-repeat="pkgCategory in pkgCategories"><span ng-show="$index">, </span><pkg-category-label pkg-category="pkgCategory"></pkg-category-label></span></span>
            </dd>
            <dt><message key="viewPkg.versionViews.title"></message></dt>
            <dd>{{pkg.versions[0].viewCounter}}</dd>
            <dt pkg="pkg" show-if-pkg-permission="'PKG_EDITPROMINENCE'">
                <message key="viewPkg.prominence.title"></message>
            </dt>
            <dd pkg="pkg" show-if-pkg-permission="'PKG_EDITPROMINENCE'">
                {{pkg.prominence.name}} ({{pkg.prominence.ordering}})
            </dd>
        </dl>

    </div>

    <div id="pkg-userratings-container" ng-show="undefined != userRatings.items">

        <div ng-show="!userRatings.items.length">
            <h2><message key="viewPkg.userRating.title"></message></h2>
            <p>
                <message key="viewPkg.userRating.noResults"></message>

                <span ng-show="isAuthenticated()">
                    <a href="" ng-click="goAddUserRating()">
                        <message key="viewPkg.userRating.noResults.addAction"></message>
                    </a>
                </span>
                <span ng-show="!isAuthenticated()">
                    <a href="" ng-click="goAuthenticate()">
                        <message key="viewPkg.userRating.noResults.authenticateAction"></message>
                    </a>
                </span>
            </p>
        </div>
        <div ng-show="userRatings.items.length">
            <h2>
                {{userRatings.total}}
                <span ng-switch="userRatings.total">
                    <span ng-switch-when="1"><message key="viewPkg.userRating.title"></message></span>
                    <span ng-switch-default=""><message key="viewPkg.userRating.title.plural"></message></span>
                </span>
            </h2>

            <div class="muted" ng-show="!isAuthenticated()">
                <small>
                    <message key="viewPkg.userRating.addAction.unauthenticated"></message>
                </small>
            </div>

            <div class="pkg-userratings-pagination">
                <pagination-control
                        link-count="9"
                        max="userRatings.max"
                        total="userRatings.total"
                        offset="userRatings.offset"></pagination-control>
            </div>

            <div style="clear:both;">
            <div class="pkg-userrating" ng-repeat="userRating in userRatings.items">
                <div class="pkg-userrating-meta">
                    <span class="muted">{{userRating.createTimestamp|date}}</span>
                    |
                    <a href="" ng-click="goViewUserRating(userRating)">
                        <message key="viewPkg.userRating.moreAction.title"></message>
                    </a>
                </div>
                <div class="pkg-userrating-indicatoranduser">
                    <rating-indicator rating="userRating.rating"></rating-indicator>
                    <message key="viewPkg.userRating.user.by"></message>
                    <user-label user="userRating.user"></user-label>
                </div>
                <div class="pkg-userrating-comment" ng-show="userRating.comment">
                    <plain-text-content value="userRating.comment" rows="3"></plain-text-content>
                </div>

                <div class="pkg-userrating-differentversion" ng-show="userRating.isOtherVersion">
                    <pkg-version-label pkg-version="userRating.pkgVersion" should-link="false"></pkg-version-label>
                </div>
            </div>
            </div>

            <ul>
                <li ng-show="isAuthenticated()">
                    <a href="" ng-click="goAddUserRating()">
                        <message key="viewPkg.userRating.addAction.title"></message>
                    </a>
                </li>
                <li pkg="pkg" show-if-pkg-permission="'BULK_USERRATINGSPREADSHEETREPORT_PKG'" ng-show="userRatings.items.length">
                    <a href="" ng-click="goDownloadUserRatings()">
                        <message key="viewPkg.downloadUserRatingsAction.title"></message>
                    </a>
                </li>
                <li show-if-permission="'USERRATING_DERIVEANDSTOREFORPKG'">
                    <a href="" ng-click="goDeriveAndStoreUserRating()">
                        <message key="viewPkg.deriveAndStoreUserRatingAction.title"></message>
                    </a>
                    <span ng-show="didDeriveAndStoreUserRating">
                        <em><message key="viewPkg.deriveAndStoreUserRatingAction.completed"></message></em>
                    </span>
                </li>
            </ul>
        </div>

    </div>

    <div id="pkg-actions-container">

        <ul>
            <li>
                <a href="" ng-click="goListPkgVersions()">
                    <message key="viewPkg.listPkgVersionsAction.title"></message>
                </a>
            </li>

            <li>
                <a target="_blank" ng-show="homePageLink()" href="{{homePageLink()}}">
                    <message key="viewPkg.visitWebSiteAction.title"></message>
                </a>
            </li>
            <li ng-show="canRemoveIcon()" pkg="pkg" show-if-pkg-permission="'PKG_EDITICON'">
                <a href="" ng-click="goRemoveIcon()">
                    <message key="viewPkg.removeIconAction.title"></message>
                </a>
            </li>
            <li pkg="pkg" show-if-pkg-permission="'PKG_EDITICON'">
                <a href="" ng-click="goEditIcon()">
                    <message key="viewPkg.editIconAction.title"></message>
                </a>
            </li>
            <li ng-show="pkgIconHvifUrl">
                <a href="{{pkgIconHvifUrl}}">
                    <message key="viewPkg.downloadIconHvifAction.title"></message>
                </a>
            </li>
            <li pkg="pkg" show-if-pkg-permission="'PKG_EDITSCREENSHOT'">
                <a href="" ng-click="goEditScreenshots()">
                    <message key="viewPkg.editScreenshotsAction.title"></message>
                </a>
            </li>
            <li
                    pkg="pkg"
                    show-if-pkg-permission="'PKG_EDITLOCALIZATION'">
                <a href="" ng-click="goEditLocalization()">
                    <message key="viewPkg.editLocalizationAction.title"></message>
                </a>
            </li>
            <li
                    ng-show="!!pkg.versions[0].isLatest"
                    pkg="pkg"
                    show-if-pkg-permission="'PKG_EDITVERSIONLOCALIZATION'">
                <a href="" ng-click="goEditVersionLocalization()">
                    <message key="viewPkg.editVersionLocalizationAction.title"></message>
                </a>
            </li>
            <li pkg="pkg" show-if-pkg-permission="'PKG_EDITPROMINENCE'">
                <a href="" ng-click="goEditPkgProminence()">
                    <message key="viewPkg.editPkgProminenceAction.title"></message>
                </a>
            </li>
            <li pkg="pkg" show-if-pkg-permission="'PKG_EDITCATEGORIES'">
                <a href="" ng-click="goEditPkgCategories()">
                    <message key="viewPkg.editPkgCategoriesAction.title"></message>
                </a>
            </li>
            <li>
                <a href="" ng-click="goViewLocalization()">
                    <message key="viewPkg.viewLocalizationAction.title"></message>
                </a>
            </li>
        </ul>
    </div>

</div>

<div class="footer"></div>
<spinner spin="shouldSpin()"></spinner>

